<%--
  Created by IntelliJ IDEA.
  User: gsb
  Date: 2019/11/22
  Time: 18:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>试卷预览</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css">
    <link rel="stylesheet" href="/lib/zTreeStyle/zTreeStyle.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/eleTree.css">

    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lims/layui/layui.js"></script>
    <script src="/lims/js/common.js?v=20190726" type="text/javascript" charset="utf-8"></script>
    <script src="/lims/js/baseCode/base.js?v=2019080918:09" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/lims/layui/global.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>

    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js/"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019080918:09" type="text/javascript" charset="utf-8"></script>
    <style>
        .layui-form-label{width:100px;}
        .layui-input-block{margin-left:130px;}
        .layui-disabled, .layui-disabled:hover{color: #797979 !important;}
        .layui-form-checkbox i{
            width: 15px;
            height: 15px;
            margin-top: 6px;
        }
        .testType{
            background: #E6E6E6;
        }
        .layui-form-radio{
            margin:0px;
            padding:0px;
        }
    </style>

<body>
<div>
    <!--
 自定义布局表单控件
 -->
    <div class="layui-fluid">
        <div class="layui-card">
<%--            <form class="layui-form" action="">--%>
                <div class="layui-card-body" style="padding: 15px;">
                    <div class="layui-card">
                        <div class="layui-card-header title" style="text-align: center;border: none;"></div>
                    </div>
                    <div class="layui-card testList">

                    </div>

                </div>
<%--            </form>--%>
        </div>
    </div>
    <script type="text/javascript">
        var id = $.GetRequest().id;
        var arr=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R'];
        var testTypeArr=['','单选题','多选题','判断题','填空题','问答题']
        var testTypeIndex=['','一','二','三','四','五']
        var eqTypeArr=['','简单','中等','困难']
        var zmIndex=0;
        var typeIndex = 1;
        function checkRadio(option,answer){
            if(option == answer){
                return true;
            }else{
                return false
            }
        }
        function checkCheckbox(option,answer){
            if(answer!=''&&answer.indexOf(option)){
                return true;
            }else{
                return false
            }
        }
        layui.use(['form','layer'],function(){
            var $ = layui.jquery,
                form = layui.form,
                layer = layui.layer;

            $.ajax({
                url:'/exaPaper/selectById',
                data:{pId:id,type:1},
                type:'get',
                dataType:'json',
                success:function(res){
                    var data = res.object;
                    if(res.code == 0){
                        var str = ''
                        $('.title').text(data.pName)
                        var len = 5;
                        var str =''
                        for(var i=1;i<=len;i++){
                            var type = i;
                            var list = 'list'+i;
                            if(data[list].length>0){
                                str += ' <div class="layui-card">\n' +
                                    '                        <div class="layui-card-body testType">'+testTypeIndex[typeIndex]+'、'+testTypeArr[type]+'（共'+data[list].length+'题，合计'+function(){
                                        var count = 0
                                        for(var m=0;m<data[list].length;m++){
                                            count += Number(data[list][m].score)
                                        }
                                        return count;
                                    }()+'分）</div>\n' +
                                    '                        <div class="layui-card-body" >'+function(){
                                    var testStr = '';


                                        for(var n=0;n<data[list].length;n++){

                                            testStr +=' <div style="line-height: 35px;">'+(n+1)+'、'+data[list][n].eqSubject+'('+data[list][n].score+'分)</div><div style="padding-left: 15px;">'+function(){
                                                var optionStr = ''
                                                if(type == 1){
                                                    if(data[list][n].option!=''&&data[list][n].option.indexOf(';')){
                                                        var optionArr = data[list][n].option.split(';');
                                                        zmIndex = 0;
                                                        var answer = data[list][n].answer
                                                        for(var i=0;i<optionArr.length;i++){
                                                            if(optionArr[i]!=''){

                                                                optionStr += '<p><input type="radio" '+function(){
                                                                    if(arr[zmIndex] == answer){
                                                                        return 'checked=checked'
                                                                    }else{
                                                                        return ''
                                                                    }
                                                                }()+'" value="'+arr[zmIndex]+'">'+optionArr[i]+'</p>'
                                                                zmIndex ++ ;
                                                            }

                                                        }
                                                    }
                                                }else if(type == 2){
                                                    if(data[list][n].option!=''&&data[list][n].option.indexOf(';')){
                                                        var optionArr = data[list][n].option.split(';');
                                                        zmIndex = 0;
                                                        var answer = data[list][n].answer
                                                        for(var i=0;i<optionArr.length;i++){
                                                            if(optionArr[i]!='') {
                                                                optionStr += '<p><input type="checkbox" '+function(){
                                                                    if(answer!=''&&answer.indexOf(arr[zmIndex])>=0){
                                                                        return 'checked=checked';
                                                                    }else{
                                                                        return ''
                                                                    }
                                                                }()+'" value="' + arr[zmIndex] + '">' + optionArr[i] + '</p>'
                                                                zmIndex++;
                                                            }
                                                        }
                                                    }
                                                }else if(type == 4){
                                                    optionStr = data[list][n].answer;
                                                }else if(type == 3){
                                                    var answer = data[list][n].answer
                                                    optionStr = '<p><input type="radio" '+function(){
                                                            if(answer == 0){
                                                                return 'checked=checked'
                                                            }else{
                                                                return ''
                                                            }
                                                        }()+'" value="0">对</p>'+
                                                        '<p><input type="radio" '+function(){
                                                            if(answer == 1){
                                                                return 'checked=checked'
                                                            }else{
                                                                return ''
                                                            }
                                                        }()+'" value="1">错</p>'
                                                }else{
                                                    optionStr = data[list][n].answer;
                                                }
                                                return optionStr;
                                            }()+'</div>'
                                        }
                                    return testStr;
                                    }()+'</div>\n' +
                                    '</div>';
                                typeIndex++;
                            }
                        }
                        $('.testList').html(str)
                    }




                    // form.render();
                }
            })

        });
    </script>
</div>
<style>
    .layui-form-checkbox i{
        border-left: 1px solid #d2d2d2;
    }
    .active{
        display: block;
    }
    .nonactive{
        display: none;
    }
    .layui-input-inline{
        margin-top:6px;
    }
    .layui-input-block{
        line-height:38px ;
    }
</style>
</body>
</html>
